package leetcode_周赛._2021._202104._20210411;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/4/11 10:32
 * 数组元素积的符号
 * 找出数组中负数的个数
 */
public class _5726 {
    public static void main(String[] args) {
        System.out.println(new _5726().arraySign(new int[]{-1,-2,-3,-4,3,2,1}));
    }

    public int arraySign(int[] nums) {
        int flag = 0;
        for (int num : nums) {
            if (num == 0) return 0;
            else if (num < 0) ++flag;
        }
        return flag % 2 != 0 ? -1 : 1;
    }
}
